package ${package.Entity};


import lombok.*;
import java.util.Date;
import java.util.List;
import ${cfg.package_name}.model.bean.*;
import com.rt.easyjava.common.base.BaseBean;


/**
 * ${table.comment!}
 * @author ${author}
 * @since ${date}
 */

@Data
@ToString
@EqualsAndHashCode(callSuper = false)
<#--@Builder-->
@AllArgsConstructor
@NoArgsConstructor
public class ${entity}Base extends BaseBean<${entity}>{

<#assign ignColumnList=["id","deleteflag","createdate","modifydate","createman","createmanId","modifyman","modifymanId","companyId","version"]/>

<#list cfg.columnList as column>
<#if (column.tableAliasName == "" || column.tableAliasName == "t1") && !ignColumnList?seq_contains(column.propertyName) >
    <#if column.isPrimaryKey=="true">
    <#if cfg.idType?? && cfg.idType=='uuid'>
    @TableId(value = "id", type = IdType.ASSIGN_UUID)
    <#elseif cfg.idType?? && cfg.idType=='none'>
    @TableId(value = "id", type = IdType.NONE)
    <#else >
    @TableId(value = "id", type = IdType.AUTO)
    </#if>
    </#if>
    private ${column.columnType4JavaEncap} ${column.propertyName};
</#if>
</#list>

<#if cfg.hasM2O>
    // Many to One
    <#list cfg.tableNameM2OList as tableNameMap>
    @TableField(exist = false)
    private ${tableNameMap.className}Biz ${tableNameMap.classInstance};
    </#list>
</#if>

<#list cfg.o2mList as o2m>
<#if o2m.hasO2M>
    // One to Many
    @TableField(exist = false)
    private List<${o2m.classNameFirstWordUpperO2M}Biz> ${o2m.classNameFirstWordLowerO2M}List;
</#if>
</#list>

<#if cfg.isTreeTable == true>
    // 当树表时，用这个存储子树
    @TableField(exist = false)
    private List<${entity}Biz> ${table.entityPath}List;
</#if>

<#--
    //----------------------------------------
    // 与页面交互时的参数
    //----------------------------------------
<#list cfg.columnList as column>
    <#if column.columnType4JavaEncap=='Timestamp'>
    private Date ${column.propertyName}_Start;
    private Date ${column.propertyName}_End;
    <#elseif column.queryType=='between'&lt;#&ndash; && column.dataResource!=5&ndash;&gt;>
    private ${column.columnType4JavaEncap} ${column.propertyName}_Start;
    private ${column.columnType4JavaEncap} ${column.propertyName}_End;
    </#if>
</#list>-->
<#------------  END 字段循环遍历  ---------->
<#--

    // 重写这个方法，return当前类的主键
    @Override
    protected Serializable pkVal() {
        return id;
    }

    // set deleteflag default 0, 查询参数时，默认只查有效数据
    public void setDeleteflagDefaultZero(){
        if(this.deleteflag==null){
            this.setDeleteflag(0);
        }
    }

    // 数据访问边界 0：全部数据， 10：机构内部数据
    public void rebuildDataLimitQueryBean(UserDetailsDto userDetailsDto){
        if (userDetailsDto==null) return;
        int dataLimitType = userDetailsDto.getDataLimitType();
        if (dataLimitType >= 10) {
            this.setCompanyId(Long.parseLong(userDetailsDto.getCompanyId()));
        }
        if (dataLimitType >= 20) {
            this.setCreatemanId(Long.parseLong(userDetailsDto.getUserId()));
        }
    }
-->

            <#--
            @Override
            public String toString() {
                return "${entity}{" +
            <#list table.fields as field>
                <#if field_index==0>
                    "${field.propertyName}=" + ${field.propertyName} +
                <#else>
                    ", ${field.propertyName}=" + ${field.propertyName} +
                </#if>
            </#list>
                "}";
            }-->
}
